package dst.ass1.jpa.model.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OrderColumn;

import dst.ass1.jpa.model.IMetadata;

@Entity
public class Metadata implements IMetadata{

	private final static Logger LOGGER = Logger.getLogger(Metadata.class.getName());
	
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	
	private String context;
	
	@ElementCollection
	@OrderColumn			//order of settings should not change after persisting and loading the entity.
	private List<String> settings = new ArrayList<String>();;
	
	public Metadata (){}
	
	@Override
	public Long getId() {
		return this.id;
	}

	@Override
	public void setId(Long id) {
		this.id=id;
	}

	@Override
	public String getContext() {
		return this.context;
	}

	@Override
	public void setContext(String description) {
		this.context=description;
	}

	@Override
	public List<String> getSettings() {
		return this.settings;
	}

	@Override
	public void setSettings(List<String> settings) {
		this.settings=settings;
	}

	@Override
	public void addSetting(String setting) {
		if(this.settings!=null){
			this.settings.add(setting);
		}
		else{
			LOGGER.info("Metadata.List<String> was null");
		}
		
	}

}
